﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace Spencen.Mobile.UI
{
    public struct DesiredSize
    {
        public const int UnboundAxis = -1;

        public static readonly DesiredSize Unbound = new DesiredSize() { Width = UnboundAxis, Height = UnboundAxis };

        public DesiredSize( int width, int height ) : this()
        {
            Width = width;
            Height = height;
        }

        public int Width { get; set; }
        public int Height { get; set; }

        public bool IsUnbound { get { return Width == UnboundAxis && Height == UnboundAxis; } }
        public bool IsXUnbound { get { return Width == UnboundAxis; } }
        public bool IsYUnbound { get { return Height == UnboundAxis; } }

        #region Operator Overloads

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        public override bool Equals( object obj )
        {
            if ( object.ReferenceEquals( this, obj ) ) return true;
            if ( obj is DesiredSize )
                return ( (DesiredSize)obj ) == this;
            else if ( obj is System.Drawing.Size )
            {
                var drawingSize = (Size)obj;
                return Width == drawingSize.Width && Height == drawingSize.Height;
            }

            return base.Equals( obj );
        }

        public static bool operator ==( DesiredSize size1, DesiredSize size2 )
        {
            return ( size1.Width == size2.Width ) && ( size1.Height == size2.Height );
        }

        public static bool operator !=( DesiredSize size1, DesiredSize size2 )
        {
            return ( size1.Width != size2.Width ) || ( size1.Height != size2.Height );
        }

        #endregion
    }
}
